package cn.tedu.sgs.notice.controller;

import cn.tedu.sgs.base.response.JsonResult;
import cn.tedu.sgs.notice.pojo.dto.NoticeQuery;
import cn.tedu.sgs.notice.pojo.dto.NoticeSaveParam;
import cn.tedu.sgs.notice.pojo.vo.NoticeVO;
import cn.tedu.sgs.notice.service.NoticeService;
import cn.tedu.sgs.record.pojo.dto.RecordSaveParam;
import cn.tedu.sgs.user.pojo.dto.UserQuery;
import cn.tedu.sgs.user.pojo.vo.UserVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/notice")
public class NoticeController {
	@Autowired
	NoticeService  noticeService;
	@GetMapping("select")
	public JsonResult selectNotice(NoticeQuery noticeQuery) {
		log.debug("查询用户:noticeQuery={}", noticeQuery);
		List<NoticeVO> list = noticeService.selectNotice(noticeQuery);
		return JsonResult.ok(list);
	}

	@PostMapping("save")
	public JsonResult saveNotice(NoticeSaveParam noticeSaveParam){
		log.debug("保存资讯:{}",noticeSaveParam);
		noticeService.saveNotice(noticeSaveParam);
		return JsonResult.ok();
	}

	@PostMapping("delete/{id}")
	public JsonResult deleteNotice(@PathVariable Long id){
		log.debug("删除资讯:{}",id);
		noticeService.deleteNotice(id);
		return JsonResult.ok();
	}
}
